function hrefPubTreeAdd_OnClick(url,scriptId,tableName,loadDiv) {
	var parentId = $("#"+scriptId).val();
	hrefTreeEdit_OnClick(url,parentId+"&tableName="+tableName,loadDiv);
}

function hrefEdit_OnClick(url,id)
{
	
	navTab.reload(url+"?id="+id);
}

function hrefTreeEdit_OnClick(url,id,jbsName)
{
	$("#"+jbsName).loadUrl(url+"?parentId="+id,"", "");
}

function checkAll(evt,checkName) {
	$("input[name='"+checkName+"']").prop("checked", evt.checked);
}

function hrefRet_OnClick(url) {
	navTab.reload(url);
}

function hrefSave_OnClick(formName,type){
	if(type == 1)
	{
		if(eval(formName+"_custom_Validate()"))
		{
			$("#"+formName).submit() ;
		}
	}else
	{
		$("#"+formName).submit() ;
	}
}


function hrefOneDel_OnClick(url,id)
{
	if(id != -1)
	{
		del_OnClick(url,{ids : id});
	}else
	{
		artDialog("question","请先保存记录");
	}
}

function hrefDel_OnClick(url,checkName) {
	hrefDel_OnClick(url,checkName,"");
}

function hrefDel_OnClick(url,checkName,arg) {
	var idlist = '';
	$("input[name='"+checkName+"']:checkbox:checked").each(function() {
		idlist += $(this).val() + ",";
	});
	if(idlist == '')
	{
		artDialog("question","请先选择要删除的行");
	}else
	{
		del_OnClick(url,{ids : idlist,args: arg});
	}

}

function hrefOneDelPub_OnClick(url,id,arg) {
	if(id != -1)
	{
		del_OnClick(url,{id : id,arg: arg});
	}else
	{
		artDialog("question","请先保存记录");
	}
}

function del_OnClick(url,datas) {
	art.dialog({
        id: 'testID',
        content: '您确定要删除数据吗？',
        button: [
            {
                name: '确定',
                callback: function () {
                	$.ajax({
            			type: 'POST',
            			url:url,
            			data: datas,
            			dataType:"json",
            			cache: false,
            			success: navTabAjaxDone || DWZ.ajaxDone,
            			error: DWZ.ajaxError
            		});
                },
                focus: true
            },
            {
                name: '取消'
            }
        ]
    });
}

function hrefSubmit_OnClick(url,checkName,arg) {
	var idlist = '';
	$("input[name='"+checkName+"']:checkbox:checked").each(function() {
		idlist += $(this).val() + ",";
	});
	if(idlist == '')
	{
		artDialog("question","请先选择要提交的行");
	}else
	{
		submit_OnClick(url,{ids : idlist,args: arg});
	}

}

function submit_OnClick(url,datas) {
	art.dialog({
        id: 'testID',
        content: '您确定要提交数据吗？',
        button: [
            {
                name: '确定',
                callback: function () {
                	$.ajax({
            			type: 'POST',
            			url:url,
            			data: datas,
            			dataType:"json",
            			cache: false,
            			success: navTabAjaxDone || DWZ.ajaxDone,
            			error: DWZ.ajaxError
            		});
                },
                focus: true
            },
            {
                name: '取消'
            }
        ]
    });
}

function hrefAffirm_OnClick(url,datas) {
	art.dialog({
        id: 'testID',
        content: '您确定吗？',
        button: [
            {
                name: '确定',
                callback: function () {
                	$.ajax({
            			type: 'POST',
            			url:url,
            			data: datas,
            			dataType:"json",
            			cache: false,
            			success: navTabAjaxDone || DWZ.ajaxDone,
            			error: DWZ.ajaxError
            		});
                },
                focus: true
            },
            {
                name: '取消'
            }
        ]
    });
}

function artDialog(type,msg)
{
	var i = 3;
	var icons = "question"; 
	if (type == 'warn') {
		icons = "warning";
	}else if (type == 'success') {
		icons = "succeed";
	}else if (type == 'error') {
		icons = "error";
		i = 20;
	}
	art.dialog({
		icon : icons,
		content : msg,
		init: function () {
	    	var that = this;
	        var fn = function () {
	            that.title(i + '秒后关闭');
	            !i && that.close();
	            i --;
	        };
	        timer = setInterval(fn, 1000);
	        fn();
	    },
	    close: function () {
	    	clearInterval(timer);
	    }
	}).show();
}

function navTabAjaxDone(data) {
	if (data.statusCode == 'success') {
		artDialog(data.statusCode,data.message)
	} else if (data.statusCode == 'error') {
		artDialog(data.statusCode,data.message)
	} else if (data.statusCode == 'noAlert') {

	}else if (data.statusCode == 'colse') {
		$.pdialog.closeCurrent();
	}else {
		artDialog("error",'连接错误');
	}
	if (data.forwardUrl != '') {
		//var url = "fsaf/fsda/aa?id=fa&loadDiv=fdsaf,loadDiv";
		var divId = "";
		var url =  data.forwardUrl;
		var s1 = parseInt(url.indexOf("loadDiv"));
		url = url.substring(s1 + 8,url.length);
		s1 = parseInt(url.indexOf("loadDiv"));
		divId = url.substring(0,s1 - 1);
		if(divId != "") {
			$("#"+divId).loadUrl(data.forwardUrl);
		}else {
		navTab.reload(data.forwardUrl);
		}
	}
}

/**
 * 在指定块上加载
 * 
 * @param DivId
 * @param url
 * @param parameters
 */
function divLoadUrl(divId,url,parameters){
	$("#"+divId).loadUrl(url+parameters);
}
function checkbox_onclick(checx)
{
	if(checx.checked)
	{
		checx.checked = false;
	}else
	{
		checx.checked = true;
	}
}

function getAutocompleteCss(term,arg1,arg2,width)
{
	if(arg1 != undefined)
	{
		var wid = 120;
		if(width=="" || width==undefined)
		{
			
		}else
		{
			wid= width;
		}
		
		var str = "<table width='"+wid+"px'><tr><td align='left'>" + 
		arg1.replace(term,"<font style='color: red; font-style: italic'>"+term+"</font>").replace(term.toUpperCase(),"<font style='color: red; font-style: italic'>"+term.toUpperCase()+"</font>")
		+ "</td>";
		
		if(arg2=="" || arg2==undefined)
		{
		}else
		{
			str = str+ "<td align='right'><font style='font-family: 黑体; font-style: italic'>" 
			+ arg2.replace(term,"<font style='color: red; font-style: italic'>"+term+"</font>").replace(term.toUpperCase(),"<font style='color: red; font-style: italic'>"+term.toUpperCase()+"</font>")
			+ "</font></td>";
		}
		str = str + "</tr></table>";
		return str;
	}
}

/**
 * 确认框确认是否ajax请求一个链接地址
 * 
 * @param url		链接地址
 * @param datas		参数（json数据）
 * @param message	提示的消息，如:您是否确定删除？
 */
function ajaxRequestHref_Confirm(url,datas,message) {
	art.dialog({
        id: 'testID',
        content: message,
        button: [
            {
                name: '确定',
                callback: function () {
                	$.ajax({
            			type: 'POST',
            			url:url,
            			data: datas,
            			dataType:"json",
            			cache: false,
            			success: navTabAjaxDone || DWZ.ajaxDone,
            			error: DWZ.ajaxError
            		});
                },
                focus: true
            },
            {
                name: '取消'
            }
        ]
    });
}
